Ad-hoc Commands

Ansible ad-hoc commands are one-time, quick execution commands that allow you to perform simple tasks on remote hosts without writing a full playbook. They are used for immediate actions like rebooting servers, installing packages, checking system status, or managing services. Ad-hoc commands are typically run from the command line and are a fast and efficient way to execute individual tasks on one or more nodes.

Key Features of Ansible Ad-hoc Commands:

No Playbook Required: Unlike playbooks, which are written in YAML and can involve complex logic, ad-hoc commands are simple, single-line commands that don’t need any YAML configuration.

Task-specific: They are used to perform specific tasks like managing services, packages, users, files, or gathering system information.

Quick Execution: These commands are useful for quick, on-the-fly tasks that don’t require complex automation.

Syntax:

ansible <host-pattern> -m <module> -a "<arguments>" [options]



Where:


<host-pattern> specifies the hosts or group of hosts from the inventory.

-m <module> specifies the Ansible module to use (like ping, shell, apt, yum, service, etc.).

-a "<arguments>" provides the arguments required by the module.

[options] are additional flags, such as -b for privilege escalation (sudo).

Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.